package com.eveinfo.display;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.ListView;
import android.widget.TextView;

import com.eveinfo.EveInfo;
import com.eveinfo.R;
import com.eveinfo.api.utils.certificates.ApiCategory;
import com.eveinfo.api.utils.certificates.ApiClass;
import com.eveinfo.display.certificates.CertificatesAdapter;

public class CertificatesView extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.certificates);

		int typeID = getIntent().getIntExtra("typeID", -1);
		int characterID = getIntent().getIntExtra("characterID", -1);

		ListView listview = (ListView) findViewById(R.id.LVCertificates);
		List<ApiCategory> categories;
		ApiClass apiClass = null;
		categories = CategoriesView.certificates.getCertificates().getCategories();
		for (ApiCategory category : categories) {
			ArrayList<ApiClass> classes = category.getClasses();
			for (ApiClass c : classes) {
				if (c.getID() == typeID) {
					apiClass = c;
					break;
				}
			}
			if (apiClass != null) {
				break;
			}
		}
		final TextView nameTV = (TextView) findViewById(R.id.TVCertificatesName);
		nameTV.setText(apiClass.getName());

		final TextView descriptionTV = (TextView) findViewById(R.id.TVCertificatesDescription);

		new CertificatesAdapter(this, listview, apiClass, descriptionTV, EveInfo.getData().getCharacterSheet(
				characterID));
	}

}
